package com.example.fw;

import static org.junit.Assert.fail;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;

public class WebDriverHelper {

	private static WebDriver driver;
	private static StringBuffer verificationErrors = new StringBuffer();
    private final ApplicationManager manager;
	
	public WebDriverHelper(ApplicationManager manager) {
		this.manager=manager;
		driver = new FirefoxDriver();
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		driver.get("http://localhost:8888/addressbookv4.1.4/index.php");
	}
	
	public void stop() {
		driver.quit();
		String verificationErrorString = verificationErrors.toString();
		if (!"".equals(verificationErrorString)) {
			fail(verificationErrorString);}	
		}

	public WebDriver getDriver() {
		return driver;
	}
}
